#include "HufArc.h"

void startTestListFunc (char * arcName, int flag)
{
	FILE * arc;
	fileHead ** list;
	int i = 0;
	int rc = 0;
	if (!arcName)
	{
		cl_exit (FUNC_INI,ERR_NAME_ARC);
	}
	arc = fopen (arcName,"rb");
	if (!arc) 
	{
		cl_exit (FUNC_INI,ERR_ARC_OPEN);
	}
	switch (flag)
	{
	case 1:
	if ((rc = testing (arc)) == 1)
		cl_exit (FUNC_INI,CS_ERR);
	fseek (arc,7,SEEK_SET);
	list = listingFile (arc);
	while (list[i])
	{
		printf ( "Name: %s\nSize: %.3f Kb\nDate: %s\n",list[i]->fileName,((float)list[i]->fileSize)/1024.0,ctime((time_t *)&list[i]->mtime));
		free (list[i]);
		i++;
	}
	break;
	case 10:
		rc = testing (arc);
		printf ("Test result: ");
		if (rc == 0 )
		{
			printf ("All is normal\n");
		} else {
			printf ("File is broken\n");
		}
		break;
	case 11:
		rc = testing (arc);
	printf ("Test result: ");
		if (rc == 0 )
		{
			printf ("All is normal\n");
		} else {
			printf ("File is broken\n");
			return;
		}
		list = listingFile (arc);
	while (list[i])
	{
		printf ( "Name: %s\nSize: %.3f Kb\nDate: %s\n",list[i]->fileName,((float)list[i]->fileSize)/1024.0,ctime((time_t *)&list[i]->mtime));
		free (list[i]);
		i++;
	}
		break;
	}
	fclose (arc);
}